package com.dpj.yygh.controller;

import com.dpj.yygh.common.result.Result;
import com.dpj.yygh.model.hosp.Schedule;
import com.dpj.yygh.service.ScheduleService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

//@CrossOrigin
@RestController
@RequestMapping("/admin/hosp/schedule")
public class ScheduleController {

    @Autowired
    ScheduleService scheduleService;

    //根据医院编号和科室编号 查询排班规则顺序
    @ApiOperation("查询排版规则数据")
    @GetMapping("/getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRule(@PathVariable long page,
                                  @PathVariable long limit,
                                  @PathVariable String hoscode,
                                  @PathVariable String depcode) {

        Map<String, Object> map
                = scheduleService.getRuleSchedule(page, limit, hoscode, depcode);
        return Result.ok(map);

    }

    @ApiOperation("查询排班详细信息")
    @GetMapping("/getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public Result getScheduleDetail(@PathVariable String hoscode,
                                    @PathVariable String depcode,
                                    @PathVariable String workDate) {
       //根据医院编号 科室编号 日期查询排班信息
        List<Schedule> list = scheduleService.getScheduleDetail(hoscode, depcode, workDate);

        return Result.ok(list);

    }

}
